package data;

import java.util.Date;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class ReasonDetail extends AbstractData {
	
	private long id =-1;
	private long hotelId;
	private String reservationIdString;
	private String reasonString;
	private String detail;
	private Date cancelDate;
	private String emailMassage;
	
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public long getHotelId() {
		return hotelId;
	}
	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}
	
	public String getReservationIdString() {
		return reservationIdString;
	}
	public void setReservationIdString(String reservationIdString) {
		this.reservationIdString = reservationIdString;
	}
	public String getReasonString() {
		return reasonString;
	}
	public void setReasonString(String reasonString) {
		this.reasonString = reasonString;
	}
	public String getDetail() {
		return detail;
	}
	public void setDetail(String detail) {
		this.detail = detail;
	}
	public Date getCancelDate() {
		return cancelDate;
	}
	public void setCancelDate(Date cancelDate) {
		this.cancelDate = cancelDate;
	}
	public String getEmailMassage() {
		return emailMassage;
	}
	public void setEmailMassage(String emailMassage) {
		this.emailMassage = emailMassage;
	}
	public Entity getEntity()
	{
		Entity item;
		
		if(this.key == null)
			item = new Entity(EntityName.ReasonDetail);
		else
			item = new Entity(this.key);
		
		item.setProperty("hotelId", this.hotelId);
		item.setProperty("ReservationId", this.reservationIdString);
		item.setProperty("Reason", this.reasonString);
		item.setProperty("Detail",this.detail);
		item.setProperty("CancelDate",this.cancelDate);
		item.setProperty("EmailMassage",this.emailMassage);
		return item;
	}

	@Override
	public void setEntity(Entity entity) {
		
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("hotelId");
		this.reservationIdString= (String) entity.getProperty("ReservationId");
	
		this.reasonString =(String) entity.getProperty("Reason");
		this.detail =(String) entity.getProperty("Detail");
		this.cancelDate =(Date) entity.getProperty("CancelDate");
		this.emailMassage =(String) entity.getProperty("EmailMassage");
		this.key = entity.getKey();
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.ReasonDetail, this.id);
			setEntity(entity);
		}
	}


}
